﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using static COC_helper.CardEdite;
using System.IO;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using TextBox = System.Windows.Forms.TextBox;


namespace COC_helper
{
    public partial class From1 : Form
    {
        /*
         public 变
         */
        public int[][] Skill_NUM; //技能点，通常，变体等
        public From1()
        {
            InitializeComponent();
        }

    



        protected void Push_Log(string context)
        {
            TextBox_Log.Text += DateAndTime.TimeString + ": \r\n";
            TextBox_Log.Text += context + "\r\n";
            Clipboard.SetDataObject("系统信息" + "\r\n" + context);
            Global_Value.MyLogHandle.LogPush("来自系统信息提示", "Info");
        }
        private void numericUpDown_Skill1_ValueChanged(object sender, EventArgs e)
        {
            // Debug.Print(e.na);
            //Debug.Print("value" + numericUpDown_Skill1.Value.ToString());


        }

        private void From1_Load(object sender, EventArgs e)
        {
            ///Global_Value.MyLogHandle.LogPush("主进程启动", "Debug");
            this.BackColor = Color.FromArgb(255, 244, 192);
            try
            {
               // Global_Value.MyLogHandle.LogPush("开始加载项目文件", "Debug");
                string temp = File.ReadAllText(".\\set.ini");


                Push_Log(DateAndTime.DateString);
                Global_Value.ZMB_PATH = System.IO.Path.GetDirectoryName(temp) + "\\";
                TextBox_FilePath.Text = Global_Value.ZMB_PATH;
                LaodAllData(File.ReadAllText(temp));
                Push_Log("已经打开最近保存的文件");
            }
            catch (Exception err)
            {
                Global_Value.MyLogHandle.LogPush("未能成功加载项目文件,错误信息:"+err.ToString(), "Debug");
                MessageBox.Show("请先在文件栏新建您的项目!!");
                //throw;
            }
            Global_Value.MyLogHandle.LogPush("加载项目文件成功", "Debug");


        }
        /// <summary>
        /// 更改属性值及重新绘制雷达图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NumericUpDown_Skill(object sender, EventArgs e)
        {
            NumericUpDown mynum = (NumericUpDown)sender;
            Debug.Print(mynum.Tag.ToString());
            int index = int.Parse(mynum.Name.Replace("numericUpDown_Skill", "")) - 1;
            chart1.Series["Data"].Points[index].SetValueY((int)mynum.Value);
            chart1.Invalidate();
            Global_Value.MyLogHandle.LogPush("用户更改了技能值为"+ mynum.Tag.ToString() 
                , "Info");

        }



        /// <summary>
        /// 双击更改技能或属性名称
        /// </summary>
        /// <param name="sneder"></param>
        /// <param name="e"></param>
        private void ChangeSkillName(object sender, MouseEventArgs e)
        {
            Label mylay = (Label)sender;
            string temp = Interaction.InputBox("请输入技能或属性的名称", "更改属性名");
            mylay.Text = temp;
            Global_Value.MyLogHandle.LogPush("用户更改了技能属性", "Info");

        }

        private void PeoList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string temp = Interaction.InputBox("请输入姓名或称号", "添加称号");
            PeoList.Items.Add(temp);
            Global_Value.MyLogHandle.LogPush("用户增加了新的NPC:"+ temp, "Info");

        }

        private void ThingList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string temp = Interaction.InputBox("请输入物品名称", "添加物品");
            ThingList.Items.Add(temp);
            Push_Log("获得物品" + temp);
        }

        private void 卡组编辑ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("卡组编辑器启动", "Info");
            new CardEdite().ShowDialog();
            //this.Hide();
            //重新绘制卡片区
            label_CardName.Text = Global_Value.zmb_Setting.fontCrad.name;
            label_info.Text = Global_Value.zmb_Setting.fontCrad.info;
            linkLabel_CardBuff.Text = Global_Value.zmb_Setting.fontCrad.buff;
            textBox2.Text = Global_Value.zmb_Setting.fontCrad.need;
            if (Global_Value.zmb_Setting.fontCrad.path != null)
                pictureBox1.Image = Image.FromFile(Global_Value.ZMB_PATH + Global_Value.zmb_Setting.fontCrad.path);
            Push_Log("卡组有新的更新");
            Global_Value.MyLogHandle.LogPush("卡组更新完成", "Info");
        }
        /// <summary>
        /// 加载所有数据
        /// </summary>
        /// <param name="Json">要加载的JSON</param>
        protected void LaodAllData(string Json)
        {
            try
            {
                Global_Value.MyLogHandle.LogPush("加载主界面数据", "Info");
                Global_Value.zmb_Setting = JsonConvert.DeserializeObject<ZMB_Setting>(Json);
                //if (Global_Value.zmb_Setting != null)
                //{

                textBox_World.Text = Global_Value.zmb_Setting.Story_Name;
                textBox_WorldLevel.Text = Global_Value.zmb_Setting.World_Level;
                textBox_PEO.Text = Global_Value.zmb_Setting.Peo_Name;
                TextBox_Cookie.Text = Global_Value.zmb_Setting.Cookie;
                textBox_Mon1.Text = Global_Value.zmb_Setting.Money_1;
                textBox_Mon2.Text = Global_Value.zmb_Setting.Money_2;
                textBox_Mon3.Text = Global_Value.zmb_Setting.Money_3;

                progressBar1.Maximum = Global_Value.zmb_Setting.State_1MAX;
                progressBar1.Value = Global_Value.zmb_Setting.State_1;
                TextBox_State1.Text = Global_Value.zmb_Setting.State_1.ToString();

                progressBar2.Maximum = Global_Value.zmb_Setting.State_2MAX;
                progressBar2.Value = Global_Value.zmb_Setting.State_2;
                TextBox_State2.Text = Global_Value.zmb_Setting.State_2.ToString();

                progressBar3.Maximum = Global_Value.zmb_Setting.State_3MAX;
                progressBar3.Value = Global_Value.zmb_Setting.State_3;
                TextBox_State3.Text = Global_Value.zmb_Setting.State_3.ToString();

                progressBar4.Maximum = Global_Value.zmb_Setting.State_4MAX;
                progressBar4.Value = Global_Value.zmb_Setting.State_4;
                TextBox_State4.Text = Global_Value.zmb_Setting.State_4.ToString();

                label_Skill1.Text = Global_Value.zmb_Setting.Skill_1str;
                label_Skill2.Text = Global_Value.zmb_Setting.Skill_2str;
                label_Skill3.Text = Global_Value.zmb_Setting.Skill_3str;
                label_Skill4.Text = Global_Value.zmb_Setting.Skill_4str;
                label_Skill5.Text = Global_Value.zmb_Setting.Skill_5str;
                label_Skill6.Text = Global_Value.zmb_Setting.Skill_6str;
                label_Skill7.Text = Global_Value.zmb_Setting.Skill_7str;
                label_Skill8.Text = Global_Value.zmb_Setting.Skill_8str;

                numericUpDown_Skill1.Value = Global_Value.zmb_Setting.Skill_1;
                numericUpDown_Skill2.Value = Global_Value.zmb_Setting.Skill_2;
                numericUpDown_Skill3.Value = Global_Value.zmb_Setting.Skill_3;
                numericUpDown_Skill4.Value = Global_Value.zmb_Setting.Skill_4;
                numericUpDown_Skill5.Value = Global_Value.zmb_Setting.Skill_5;
                numericUpDown_Skill6.Value = Global_Value.zmb_Setting.Skill_6;
                numericUpDown_Skill7.Value = Global_Value.zmb_Setting.Skill_7;
                numericUpDown_Skill8.Value = Global_Value.zmb_Setting.Skill_8;


                ThingList.Items.Clear();
                foreach (var item in Global_Value.zmb_Setting.PlayerThingList)
                {
                    ThingList.Items.Add(item);
                }
                foreach (var item in Global_Value.zmb_Setting.PeopleList)
                {
                    PeoList.Items.Add(item);
                }
                label_CardName.Text = Global_Value.zmb_Setting.fontCrad.name;
                label_info.Text = Global_Value.zmb_Setting.fontCrad.info;
                linkLabel_CardBuff.Text = Global_Value.zmb_Setting.fontCrad.buff;
                textBox2.Text = Global_Value.zmb_Setting.fontCrad.need;
                if (Global_Value.zmb_Setting.fontCrad.path != null)
                    pictureBox1.Image = Image.FromFile(Global_Value.ZMB_PATH + Global_Value.zmb_Setting.fontCrad.path);
                //}
                Global_Value.MyLogHandle.LogPush("技能面板绘制正常","Debug");

            }
            catch (Exception Err)
            {
                Global_Value.MyLogHandle.LogPush("加载有问题: " + Err.ToString(), "Error");
               
                //throw;
            }
            chart1.Series.Clear();
            chart1.ChartAreas[0].AxisX.Interval = 1;
            chart1.ChartAreas[0].AxisY.Minimum = 0;
            chart1.ChartAreas[0].AxisY.Maximum = 100;
            var series = new Series("Data");
            series.ChartType = SeriesChartType.Radar;
            series.BorderWidth = 3;
            series.BorderColor = Color.Orange;
            ChartArea area = chart1.ChartAreas[0];

            // ========== 隐藏所有坐标轴线 ==========
            // X轴（径向轴）
            area.AxisX.LineColor = Color.Gray;
            area.AxisX.MajorGrid.LineColor = Color.Gray; // 可选：隐藏径向网格线
            area.AxisX.MinorGrid.Enabled = true;

            // Y轴（角度轴）
            area.AxisY.LineColor = Color.Transparent;
            area.AxisY.MajorGrid.LineColor = Color.Transparent; // 保留环形网格线（可选）

            area.AxisY.MinorGrid.Enabled = false;

            area.AxisX.MajorTickMark.Enabled = false;
            area.AxisX.MinorTickMark.Enabled = false;
            area.AxisY.MajorTickMark.Enabled = true;
            area.AxisY.MinorTickMark.Enabled = false;

            area.AxisX.LabelStyle.Enabled = false;
            area.AxisY.LabelStyle.Enabled = false;

            numericUpDown_Skill1.ValueChanged += NumericUpDown_Skill;
            numericUpDown_Skill2.ValueChanged += NumericUpDown_Skill;
            numericUpDown_Skill3.ValueChanged += NumericUpDown_Skill;
            numericUpDown_Skill4.ValueChanged += NumericUpDown_Skill;
            numericUpDown_Skill5.ValueChanged += NumericUpDown_Skill;
            numericUpDown_Skill6.ValueChanged += NumericUpDown_Skill;
            numericUpDown_Skill7.ValueChanged += NumericUpDown_Skill;
            numericUpDown_Skill8.ValueChanged += NumericUpDown_Skill;

            series.Points.AddXY(0, Global_Value.zmb_Setting.Skill_1);
            series.Points.AddXY(1, Global_Value.zmb_Setting.Skill_2);
            series.Points.AddXY(2, Global_Value.zmb_Setting.Skill_3);
            series.Points.AddXY(3, Global_Value.zmb_Setting.Skill_4);
            series.Points.AddXY(4, Global_Value.zmb_Setting.Skill_5);
            series.Points.AddXY(5, Global_Value.zmb_Setting.Skill_6);
            series.Points.AddXY(6, Global_Value.zmb_Setting.Skill_7);
            series.Points.AddXY(7, Global_Value.zmb_Setting.Skill_8);

            chart1.Series.Add(series);
            chart1.Invalidate();
            Push_Log("系统就绪");
            Global_Value.MyLogHandle.LogPush("加载主界面数据完成", "Info");
        }


        /// <summary>
        /// 保存所有数据
        /// </summary>
        protected void SaveAllData()
        {
            Global_Value.MyLogHandle.LogPush("开始保存主界面数据", "Info");
            Global_Value.zmb_Setting.Money_1 = textBox_Mon1.Text;
            Global_Value.zmb_Setting.Money_2 = textBox_Mon2.Text;
            Global_Value.zmb_Setting.Money_3 = textBox_Mon3.Text;
            Global_Value.zmb_Setting.Peo_Name = textBox_PEO.Text;
            Global_Value.zmb_Setting.Story_Name = textBox_World.Text;
            Global_Value.zmb_Setting.World_Level = textBox_WorldLevel.Text;
            Global_Value.zmb_Setting.Cookie = TextBox_Cookie.Text;
            Global_Value.zmb_Setting.Skill_1 = (int)numericUpDown_Skill1.Value;
            Global_Value.zmb_Setting.Skill_2 = (int)numericUpDown_Skill2.Value;
            Global_Value.zmb_Setting.Skill_3 = (int)numericUpDown_Skill3.Value;
            Global_Value.zmb_Setting.Skill_4 = (int)numericUpDown_Skill4.Value;
            Global_Value.zmb_Setting.Skill_5 = (int)numericUpDown_Skill5.Value;
            Global_Value.zmb_Setting.Skill_6 = (int)numericUpDown_Skill6.Value;
            Global_Value.zmb_Setting.Skill_7 = (int)numericUpDown_Skill7.Value;
            Global_Value.zmb_Setting.Skill_8 = (int)numericUpDown_Skill8.Value;
            Global_Value.zmb_Setting.Skill_1str = label_Skill1.Text;
            Global_Value.zmb_Setting.Skill_2str = label_Skill2.Text;
            Global_Value.zmb_Setting.Skill_3str = label_Skill3.Text;
            Global_Value.zmb_Setting.Skill_4str = label_Skill4.Text;
            Global_Value.zmb_Setting.Skill_5str = label_Skill5.Text;
            Global_Value.zmb_Setting.Skill_6str = label_Skill6.Text;
            Global_Value.zmb_Setting.Skill_7str = label_Skill7.Text;
            Global_Value.zmb_Setting.Skill_8str = label_Skill8.Text;

            Global_Value.zmb_Setting.State_1 = progressBar1.Value;
            Global_Value.zmb_Setting.State_1MAX = progressBar1.Maximum;
            Global_Value.zmb_Setting.State_2 = progressBar2.Value;
            Global_Value.zmb_Setting.State_2MAX = progressBar2.Maximum;
            Global_Value.zmb_Setting.State_3 = progressBar3.Value;
            Global_Value.zmb_Setting.State_3MAX = progressBar3.Maximum;
            Global_Value.zmb_Setting.State_4 = progressBar4.Value;
            Global_Value.zmb_Setting.State_4MAX = progressBar4.Maximum;
            Global_Value.zmb_Setting.PlayerThingList.Clear();
            Global_Value.zmb_Setting.PeopleList.Clear();
            foreach (var item in ThingList.Items)
            {
                Global_Value.zmb_Setting.PlayerThingList.Add(item);
            }
            foreach (var item in PeoList.Items)
            {
                Global_Value.zmb_Setting.PeopleList.Add(item);
            }

            string Json = JsonConvert.SerializeObject(Global_Value.zmb_Setting, Formatting.Indented);
            Debug.WriteLine(Json);
          
            try
            {
                File.WriteAllText(TextBox_FilePath.Text + textBox_World.Text + ".json", Json);
                Push_Log("保存至文件" + textBox_World.Text);
                Global_Value.MyLogHandle.LogPush("保存主界面数据完成", "Info");
            }
            catch (Exception err)
            {
                Debug.WriteLine("文件没有成功保存，因为：" + err.ToString());
                Global_Value.MyLogHandle.LogPush("保存主界面数据异常"+err.ToString(), "Info");
                // throw;
            }
        }
        private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveAllData();
            Push_Log("项目文件已经保存:" + DateAndTime.TimeString.ToString());
            File.WriteAllText(".\\set.ini", Global_Value.ZMB_PATH + textBox_World.Text + ".json");
            Global_Value.MyLogHandle.LogPush("保存至"+ Global_Value.ZMB_PATH, "Info");
        }

        private void 关系表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("启动派系关系表示器", "Info");
            new Relate().ShowDialog();
            Push_Log("派系关系表示器,已更新");
        }

        private void TextBox_FilePath_TextChanged(object sender, EventArgs e)
        {
            Global_Value.ZMB_PATH = TextBox_FilePath.Text;
        }



        private void 自定义记事本ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new NoteBook().ShowDialog();
        }



        private void Button_Test_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("开始运行检定模块", "Info");
            Random random = new Random();
            int temp = random.Next(100);
            label_Skill1.ForeColor = temp <= numericUpDown_Skill1.Value ? Color.Green : Color.Red;
            label_Skill2.ForeColor = temp <= numericUpDown_Skill2.Value ? Color.Green : Color.Red;
            label_Skill3.ForeColor = temp <= numericUpDown_Skill3.Value ? Color.Green : Color.Red;
            label_Skill4.ForeColor = temp <= numericUpDown_Skill4.Value ? Color.Green : Color.Red;
            label_Skill5.ForeColor = temp <= numericUpDown_Skill5.Value ? Color.Green : Color.Red;
            label_Skill6.ForeColor = temp <= numericUpDown_Skill6.Value ? Color.Green : Color.Red;
            label_Skill7.ForeColor = temp <= numericUpDown_Skill7.Value ? Color.Green : Color.Red;
            label_Skill8.ForeColor = temp <= numericUpDown_Skill8.Value ? Color.Green : Color.Red;
            linkLabel_Test.Text = "检定值:" + temp.ToString();

        }

        private void Label_Click(object sender, EventArgs e)
        {
            Label mynum = (Label)sender;

            Push_Log("对 " + mynum.Text.ToString() + " 检定结果为:" + (mynum.ForeColor == Color.Green ? "成功 " : "失败 ") + linkLabel_Test.Text + "\n");
        }

        private void Button_ThingList_Add_Click(object sender, EventArgs e)
        {
            string temp = Interaction.InputBox("请输入物品名称", "添加物品");
            if (temp == "")
                return;
            ThingList.Items.Add(temp);
            Push_Log("物品栏添加物品:" + temp);
        }

        private void Button_ThingList_Chanage_Click(object sender, EventArgs e)
        {
            if (ThingList.SelectedItem == null)
            {
                Debug.Write("没有指向元素?");
                Global_Value.MyLogHandle.LogPush("无法更改物品,因为没有所指", "Warn");
                return;
            }
            string temp = Interaction.InputBox("请输入物品名称", "更改物品");
            if (temp == "")
                return;
            Push_Log("物品" + ThingList.SelectedItem + "被更改为" + temp);
            ThingList.Items.Remove(ThingList.SelectedItem);
            ThingList.Items.Add(temp);
        }

        private void Button_ThingList_Remove_Click(object sender, EventArgs e)
        {
            if (ThingList.SelectedItem == null)
            {
                Debug.Write("没有指向元素?");
                Global_Value.MyLogHandle.LogPush("无法移除物品,因为没有所指", "Warn");
                return;
            }
            Push_Log("移除了" + ThingList.SelectedItem);
            ThingList.Items.Remove(ThingList.SelectedItem);

        }


        public void StateVlaue_Chanage(object sender, EventArgs e)
        {

            TextBox mytextbox = (TextBox)sender;
            //mytextbox.Text = Interaction.InputBox(" 请输入新的值","更改");
            try
            {
                switch (mytextbox.Tag)
                {
                    case "1":
                        progressBar1.Value = int.Parse(mytextbox.Text);
                        break;
                    case "2":
                        progressBar2.Value = int.Parse(mytextbox.Text);
                        break;
                    case "3":
                        progressBar3.Value = int.Parse(mytextbox.Text);
                        break;
                    case "4":
                        progressBar4.Value = int.Parse(mytextbox.Text);
                        break;
                    default:
                        break;
                }

            }
            catch (Exception err)
            {
                Debug.Write(err.ToString());
                return;
                //throw;
            }


        }

        private void 随从面板ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("启动人物编辑器", "Info");
            new SlavePla().ShowDialog();
            PeoList.Items.Clear();
            foreach (SlaveList item in Global_Value.zmb_Setting.slaveLists)
            {
                PeoList.Items.Add(item.Name);

            }
            Push_Log("随从人员列表已更新");
        }

        private void 打开项目ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "打开上古安剧情文件";
            openFileDialog1.Multiselect = false;
            openFileDialog1.Filter = "配置文件(.json)|*.json";
            openFileDialog1.InitialDirectory = Global_Value.ZMB_PATH;
            openFileDialog1.DefaultExt = "json";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (MessageBox.Show("您当前的剧本文件还没有保存,是否保存?", "上古安服务中心", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    SaveAllData();
                Global_Value.ZMB_PATH = System.IO.Path.GetDirectoryName(openFileDialog1.FileName) + "\\";
                TextBox_FilePath.Text = Global_Value.ZMB_PATH;
                try
                {
                    LaodAllData(File.ReadAllText(openFileDialog1.FileName));
                    Push_Log("已经加载文件:" + openFileDialog1.FileName);
                }
                catch (Exception)
                {


                }
            }
        }

        private void 项目另存为ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog1.AddExtension = true;
            saveFileDialog1.Filter = "配置文件(.json)|*.json";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string Json = JsonConvert.SerializeObject(Global_Value.zmb_Setting, Formatting.Indented);
                //Debug.WriteLine(Json);
                try
                {

                    File.WriteAllText(saveFileDialog1.FileName, Json);
                    Push_Log("项目文件已经另存为:" + saveFileDialog1.FileName);
                }
                catch (Exception err)
                {
                    Debug.WriteLine("文件没有成功保存，因为：" + err.ToString());
                    Push_Log("文件保存失败了");
                    // throw;
                }
            }
            //SaveAllData();
        }

        private void 新建项目ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ZMB_Setting zMB_Setting = new ZMB_Setting()
            {
                Skill_1str = "NONE",
                Skill_2str = "NONE",
                Skill_3str = "NONE",
                Skill_4str = "NONE",
                Skill_5str = "NONE",
                Skill_6str = "NONE",
                Skill_7str = "NONE",
                Skill_8str = "NONE",
                State_1MAX = 100,
                State_2MAX = 100,
                State_3MAX = 100,
                State_4MAX = 100,
            };
            saveFileDialog1.AddExtension = true;
            saveFileDialog1.Filter = "配置文件(.json)|*.json";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string Json = JsonConvert.SerializeObject(zMB_Setting, Formatting.Indented);
                //Debug.WriteLine(Json);
                try
                {

                    File.WriteAllText(saveFileDialog1.FileName, Json);
                    Global_Value.ZMB_PATH = System.IO.Path.GetDirectoryName(saveFileDialog1.FileName) + "\\";
                    LaodAllData(Json);
                    Push_Log("新的文件已经就绪");
                }
                catch (Exception err)
                {
                    Debug.WriteLine("文件没有成功保存，因为：" + err.ToString());
                    // throw;
                }
            }
        }

        private void Button_EXIT_Click(object sender, EventArgs e)
        {
            Push_Log(DateAndTime.DateString);
            Push_Log("开始保存并退出");
            SaveAllData();
            Push_Log("主线已退出");
            Push_Log("-----------------------------------end--------------------------------------------");
            Push_Log(" ");

            try
            {
                File.WriteAllText(".\\set.ini", Global_Value.ZMB_PATH + textBox_World.Text + ".json");
                File.AppendAllText(Global_Value.ZMB_PATH + DateAndTime.DateString + ".log", "---------------------------------start--------------------------------" + TextBox_Log.Text);

            }
            catch (Exception)
            {

                // throw;
            }
            this.Close();

        }

        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("启动人物编辑器", "Info");
            new PeoInfo().ShowDialog();
        }

        private void 地图预览ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("启动地图编辑器", "Info");
            new MapLeader().ShowDialog();
        }

        private void 会话管理器ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("启动会话编辑器", "Info");
            new SessionLeader().ShowDialog();
        }

        private void Button_myTest_Click(object sender, EventArgs e)
        {
            Random random = new Random();
            int temp = random.Next(100);
            Push_Log("自定义检定：对" + TextBox_myTest.Text + "的检定结果为" 
                + (numericUpDown_myTest.Value > temp ? "成功":"失败")
                + "("
                + numericUpDown_myTest.Value
                + '/'
                + temp
                + ')'
                );
        }

        private void 成就管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Global_Value.MyLogHandle.LogPush("启动成就编辑器", "Info");
            new Achievement().ShowDialog();
            if (Global_Value.CallBackLog != null)
                Push_Log(Global_Value.CallBackLog);
            Global_Value.CallBackLog = null;

        }

        private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("上古安剧情服务中心使用");
        }

        private void 文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
    }
}
